import request from '@/utils/request'
import qs from 'qs';

export function login(data) {
  return request({
    // url: '/vue-admin-template/user/login',
    url:"/resource/public/login",
    method: 'post',
    data
    // headers: {
    //   'Content-Type':'application/x-www-form-urlencoded'
    // },
    // data:qs.stringify(data),
  })
}

export function getRoleList(params) {
  return request({
    url: '/resource/rbac/index',
    method: 'get',
    params
  })
}


export function getMenuList() {
  return request({
    url: '/resource/rbac/menu',
    method: 'get',
  })
}

export function addRole(data) {
  return request({
    url: '/resource/rbac/roleAdd',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}


export function delRole(data) {
  return request({
    url: '/resource/rbac/roleDelete',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}

// 获取角色信息
export function getMenuSelect(params) {
  return request({
    url: '/resource/rbac/info',
    method: 'get',
    params
  })
}


// 编辑角色
export function editRole(data) {
  return request({
    url: '/resource/rbac/roleEdit',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}



// 用户权限

// 用户列表
export function getUserlist(params){
  return request({
    url: '/resource/user/index',
    method: 'get',
    params
  })
}


// 添加用户
export function addUser(data){
  return request({
    url: '/resource/user/add',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}

// 删除用户
export function delUser(data) {
  return request({
    url: '/resource/user/delete',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}

//禁用用户
export function blackUser(data) {
  return request({
    url: '/resource/user/ban',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}


//启用用户
export function openUser(data) {
  return request({
    url: '/resource/user/cancelBan',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}

// 获取用户详情
export function getUserItem(params){
  return request({
    url: '/resource/user/info',
    method: 'get',
    params
  })
}

// 修改用户
export function editUser(data) {
  return request({
    url: '/resource/user/edit',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}


export function setSaleAuto(data) {
  return request({
    url: '/resource/user/setSaleAuto',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}


export function getSaleAuto(params){
  return request({
    url: '/resource/user/saleSetData',
    method: 'get',
    params
  })
}


// 组织管理列表
export function getUserGroup(params){
  return request({
    url: '/resource/user_group/index',
    method: 'get',
    params
  })
}

// 编辑
export function groupEdit(data) {
  return request({
    url: '/resource/user_group/groupEdit',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}

// 查看详情
export function getGroupInfo(params){
  return request({
    url: '/resource/user_group/getGroupInfo',
    method: 'get',
    params
  })
}

// 添加
export function groupAdd(data) {
  return request({
    url: '/resource/user_group/groupAdd',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}


// 删除
export function groupDel(data) {
  return request({
    url: '/resource/user_group/groupDel',
    method: 'post',
    headers: {
      'Content-Type':'application/x-www-form-urlencoded'
    },
    data:qs.stringify(data),
  })
}


// 成员用户列表
export function getusergrouplist(params){
  return request({
    url: '/resource/user_group/userlist',
    method: 'get',
    params
  })
}


